<template>
  <!-- <a-card title="处理意见" :bodyStyle="{paddingTop:'0px'}" size="small"> -->
    <a-list item-layout="vertical" >
      <a-list-item>
        <div style="margin-bottom:10px;">
          <label>处理意见：</label>
          <a-radio-group v-model="approvalData.flag">
            <a-radio :value="0">同意</a-radio>
            <a-radio v-if="taskData.nodeType === 0" :value="1">不同意</a-radio>
            <a-radio :value="2" v-if="historyNode.length>0">驳回</a-radio>
          </a-radio-group>
          <a-select v-if="approvalData.flag === 2" placeholder="请选择驳回的节点" style="width: 300px;" @change="nodeChange">
            <template v-for="(node,index) in historyNode">
              <a-select-option :key="index" :value="node.nodeId">{{node.nodeName}}</a-select-option>
            </template>
          </a-select>
          <a-divider type="vertical" />
          <j-upload style="display:inline-block;" v-model="approvalData.files"></j-upload>
        </div>
      </a-list-item>
      <a-list-item>
        <label>审批意见：</label>
        <!-- <a-select placeholder="常用审批语" style="width: 300px;" @change="optionChange">
          <template v-for="(option,index) in HandlingOpinions">
            <a-select-option :key="index" :value="option">{{option}}</a-select-option>
          </template>
        </a-select> -->
        <a-input type="textarea" style="margin-top:20px;" :rows="3" v-model="approvalData.reason"/>
      </a-list-item>
      <!-- <a-list-item>
        <j-upload v-model="approvalData.files"></j-upload>
      </a-list-item> -->
    </a-list>
  <!-- </a-card> -->
</template>

<script>
import { getHistoryNode } from '@/api/task'
import JUpload from '@/components/jeecg/JUpload'
import Vue from 'vue'
import { ACCESS_TOKEN } from '@/store/mutation-types'
export default {
  name: 'taskApprovalCard',
  components: {
    JUpload
  },
  props: {
    taskData: {
      type: Object,
      default: () => {}
    }
  },
  data() {
    return {
      HandlingOpinions: [
        '同意',
        '同意***意见',
        '请指示',
        '同意***阅示',
        '请处理',
        '不同意',
        '呈领导阅示',
        '请审批'
      ],
      approvalData: {
        flag: 0,
        reason: '',
        files: '', // 上传文件地址
        nodeId: ''// 驳回的节点
      },
      isAppointnextUser: false, // 是否指定下一步操作人
      iscc: false, // 是否抄送
      historyNode: [],
      action: '', // 文件上传地址
      headers: {}

    }
  },
  methods: {
    optionChange(value, option) {
      this.approvalData['reason'] = value
    },
    nodeChange(value, option) {
      this.approvalData['nodeId'] = value
    }
  },
  mounted() {
    this.action = window._CONFIG['domianURL'] + '/sys/common/upload'
    const token = Vue.ls.get(ACCESS_TOKEN)
    this.headers = { 'X-Access-Token': token }
    getHistoryNode({
      procInstId: this.taskData.processInstanceId,
      taskId: this.taskData.id
    }).then(res => {
      if (res.success) {
        this.historyNode = res.result
      }
    })
  }
}
</script>
